<template>
	<view class="p-my-account">
		<!-- 导航栏 -->
		<u-navbar
			title="宸坤美食"
			:is-back="true"
			:title-bold="true"
			:background="background"
			title-color="#fff"
			:border-bottom="false"
		></u-navbar>
		<!-- 主体内容 -->
		<view class="content_box">
			<view class="title">
				<text>账号信息</text>
			</view>
			
			<!-- 选项 -->
			<view class="option_box">
				<view class="option_item" @click="nickNameModify">
					<u-section title="姓名" :sub-title="userInfo.nickName" :show-line="false"></u-section>
					<u-line />
				</view>
				<view class="option_item" @click="mobilePhoneModify">
					<u-section title="手机号" :sub-title="userInfo.mobilePhone" :show-line="false"></u-section>
					<u-line />
				</view>
				<view class="option_item">
					<u-section title="公司" sub-title=" " :show-line="false"></u-section>
					<u-line />
				</view>
				<view class="option_item">
					<u-section title="公司人数" sub-title=" " :show-line="false"></u-section>
					<u-line />
				</view>
			</view>
		</view>

	</view>
</template>

<script>
import { wacUserInfo } from '@/api/user'

export default {
	components: {
	},
	data() {
		return {
			background: {
				backgroundColor: '#ff9900'
			},
			// 登录code
			loginCode: '',
			// 用户信息
			userInfo: {},
			// 微信用户信息
			wxUserInfo: {},
			// 默认头像
			defaultAcatar: 'https://ckscm.oss-cn-shenzhen.aliyuncs.com/rop_applet_material/image/default.jpeg'
		}
	},
	onLoad() {},
	onShow() {
		try {
			const value = uni.getStorageSync('token')
			if (value) {
				this.getUserInfo()
			} else {
				this.getWxUserInfo()
				this.userInfo = {}
			}
		} catch (e) {
			// error
			this.getWxUserInfo()
			this.userInfo = {}
		}
	},
	methods: {
		// 获取用户信息
		async getUserInfo() {
			const { data } = await wacUserInfo()
			this.userInfo = data
		},

		// 修改手机号
		mobilePhoneModify() {
			this.$refs.contact.open()
		},
		// 修改昵称
		nickNameModify() {
			uni.navigateTo({
				url: '/pages/my/account/nickName'
			})
		}
	}
}
</script>

<style>
page {
	background-color: #eeeeee;
}
</style>

<style scoped lang="scss">
.p-my-account{background: #fff;}
.content_box{
	.title{
		margin: 40rpx;
		border-left:10rpx solid #F1AB39;
		text{
			padding-left: 8rpx;
			font-size: 36rpx;
		}
	}
}
::v-deep .u-section {
	padding: 40rpx
}
</style>
